home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / printfault.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  89 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: printfault.c,v 1.3 1996/08/13 13:52:49 digulla Exp $
  4.     $Log: printfault.c,v $
  5.     Revision 1.3  1996/08/13 13:52:49  digulla
  6.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  7.     Replaced __AROS_LA by __AROS_LHA
  8.  
  9.     Revision 1.2  1996/08/01 17:40:55  digulla
  10.     Added standard header for all files
  11.  
  12.     Desc:
  13.     Lang: english
  14. */
  15. #include <clib/exec_protos.h>
  16. #include "dos_intern.h"
  17.  
  18. /*****************************************************************************
  19.  
  20.     NAME */
  21.     #include <clib/dos_protos.h>
  22.  
  23.     __AROS_LH2(BOOL, PrintFault,
  24.  
  25. /*  SYNOPSIS */
  26.     __AROS_LHA(LONG,   code,   D1),
  27.     __AROS_LHA(STRPTR, header, D2),
  28.  
  29. /*  LOCATION */
  30.     struct DosLibrary *, DOSBase, 79, Dos)
  31.  
  32. /*  FUNCTION
  33.     Prints the header and the text associated with the error code to
  34.     the console (buffered), then sets the value returned by IoErr() to
  35.     the error code given.
  36.  
  37.     INPUTS
  38.     code   - Error code.
  39.     header - Text to print before the error message.
  40.  
  41.     RESULT
  42.     !=0 if all went well. 0 on failure.
  43.  
  44.     NOTES
  45.  
  46.     EXAMPLE
  47.  
  48.     BUGS
  49.  
  50.     SEE ALSO
  51.  
  52.     INTERNALS
  53.  
  54.     HISTORY
  55.     29-10-95    digulla automatically created from
  56.                 dos_lib.fd and clib/dos_protos.h
  57.  
  58. *****************************************************************************/
  59. {
  60.     __AROS_FUNC_INIT
  61.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  62.  
  63.     struct Process *me=(struct Process *)FindTask(NULL);
  64.     BPTR stream=me->pr_CES?me->pr_CES:me->pr_COS;
  65.     struct EString *es=EString;
  66.     BOOL ret=0;
  67.  
  68.     /* First find error string */
  69.     while(es->Number)
  70.     {
  71.     if(es->Number==code)
  72.         break;
  73.     es++;
  74.     }
  75.  
  76.     /* Print everything */
  77.     if(!FPuts(stream,header)&&
  78.        !FPuts(stream,": ")&&
  79.        !FPuts(stream,es->String)&&
  80.        !FPuts(stream,"\n"))
  81.     ret=1;
  82.  
  83.     /* All done. */
  84.     me->pr_Result2=code;
  85.     return ret;
  86.  
  87.     __AROS_FUNC_EXIT
  88. } /* PrintFault */
  89.